	$(function() {
		//根据id加载新闻详情
		//readNewsDetails(id);
		//上一篇&&下一篇加载
		//readDetailsUpInDn();
	});
	
	var baseUrl = "";
	
	var minid = 0;  //记录最小id
	
	var maxid = 999;  //记录最大id
	
	//根据id加载新闻详情
	function readNewsDetails(typeId){
		var data = {
				id : parseInt(typeId)
			};
		$.ajax({
			url:baseUrl+'/informationController/selectInformationById',
			data :data,
			type : 'POST',
			dataType: "JSON",
			async: false,
			success : function(result) {
				if(result!=null){
					var base = new Base64();
					$("#newsDetails_head_type").attr("data_id",result.informationTypeId);
					$("#news_details_name").text(result.name); //标题
					$("#news_details_editors").text(result.editors); //编辑人
					$("#news_details_update").text(result.update); //发布时间
					$("#news_details_content").html(base.decode(result.content)); //内容
				}else{
					$("#product_list").html("暂无数据");
				}
			},
			error: function (result) {
			}
		});
	}
	
	//上一篇&&下一篇加载
	function readDetailsUpInDn(){
		var type_id = $("#newsDetails_head_type").attr("data_id");
		//首先查询当前分类下的最小和最大id
		readMinAndMaxId(type_id);
		$.ajax({
			type: "POST",
			dataType: "JSON",
			url:baseUrl+'/informationController/selecUpInDn',
			data: {
				typeId:	type_id,
				id: id
			},
			success: function (result) {
				if(result!=null){
					if(result.length==0){
						//上一篇
						$("#details_page_up").text("已经到底了");
						$("#details_page_up").attr("data_id","0");
						//下一篇
						$("#details_page_dn").text("已经到底了");
						$("#details_page_dn").attr("data_id","0");
					}else if(result.length==1){
						if(parseInt(id)==minid){
							//上一篇
							$("#details_page_up").text("已经到底了");
							$("#details_page_up").attr("data_id","0");
							//下一篇
							$("#details_page_dn").text(result[0].name);
							$("#details_page_dn").attr("data_id",result[0].id);
						}else if(parseInt(id)==maxid){
							//上一篇
							$("#details_page_up").text(result[0].name);
							$("#details_page_up").attr("data_id",result[0].id);
							//下一篇
							$("#details_page_dn").text("已经到底了");
							$("#details_page_dn").attr("data_id","0");
						}
					}else{
						//上一篇
						$("#details_page_up").text(result[0].name);
						$("#details_page_up").attr("data_id",result[0].id);
						//下一篇
						$("#details_page_dn").text(result[1].name);
						$("#details_page_dn").attr("data_id",result[1].id);
					}
				}else{
					$("#newsDetails_head_type").html("暂无数据");
				}
			},
			error: function (result) {
			}
		});
	}
	
	//点击上一篇跳转
	$(document).on("click","#details_page_up",function(e){
		var dataId = $(this).attr("data_id");
		if(dataId!=0&&dataId!="0"){
			window.location.href=baseUrl+"/zxxq/"+dataId;
		}else{
			alert('已经到底了。');
		}
	});
	
	//点击下一篇跳转
	$(document).on("click","#details_page_dn",function(e){
		var dataId = $(this).attr("data_id");
		if(dataId!=0&&dataId!="0"){
			window.location.href=baseUrl+"/zxxq/"+dataId;
		}else{
			alert('已经到底了。');
		}
	});

	//查询当前分类下的最小和最大id
	function readMinAndMaxId(typeId){
		$.ajax({
			type: "POST",
			dataType: "JSON",
			async: false,
			url:baseUrl+'/informationController/selecMinAndMaxId',
			data: {
				id:	  typeId
			},
			success: function (result) {
				if(result!=null){
					minid = result.minid;
					maxid = result.maxid;
				}
			},
			error: function (result) {
			}
		});
	}
	
